package br.uefs.dexa.rfframework.gui.utils;

import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;

import br.uefs.dexa.rfframework.gui.config.dialogs.NewCollectionDialog;


public class CustomMenuBar extends JMenuBar {
	
	//File menu
	private JMenu fileMenu;
	private JMenuItem newMenuItem;
	private JMenuItem exitMenuItem;
	
	//New submenu itens
	private JMenuItem collectionMenuItem;
	private JMenuItem featureMenuItem;
	private JMenuItem strategyMenuItem;
	
	//Run menu
	private JMenu runMenu;
	private JMenuItem runQueryMenuItem;
	
	//Help menu
	private JMenu helpMenu;
	private JMenuItem aboutMenuItem;
	
	
	public CustomMenuBar()
	{
		buildMenu();
	}
	
	private void buildMenu()
	{
		buildMenuBar();
		buildFileMenu();
		
	}
	
	private void buildMenuBar()
	{
		fileMenu = new JMenu("File");
		runMenu = new JMenu("Run");
		helpMenu = new JMenu("Help");
		
		add(fileMenu);
		add(runMenu);
		add(helpMenu);
	}
	
	private void buildFileMenu()
	{
		buildNewMenuItem();
		buildCollectionMenuItem();
		buildExitMenuItem();
		
		fileMenu.add(newMenuItem);
		fileMenu.add(exitMenuItem);
	}
	
	private void buildNewMenuItem()
	{
		newMenuItem = new JMenu("New...");
		
		collectionMenuItem = new JMenuItem("Collection");
		featureMenuItem = new JMenuItem("Feature");
		strategyMenuItem = new JMenuItem("Strategy");
		
		newMenuItem.add(collectionMenuItem);
		newMenuItem.add(featureMenuItem);
		newMenuItem.add(strategyMenuItem);
		
	}
	
	private void buildExitMenuItem()
	{
		exitMenuItem = new JMenuItem("Exit");
		exitMenuItem.setPreferredSize(new Dimension(100, 20));
		
		exitMenuItem.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				System.exit(0);
			}
		});
	}
	
	private void buildCollectionMenuItem()
	{
		
		collectionMenuItem.addActionListener(new ActionListener() {
			
			@Override
			public void actionPerformed(ActionEvent e) {
				//NewCollectionDialog dialog = new NewCollectionDialog();
				//dialog.setVisible(true);
			}
		});
	}

}
